﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OrderAdd.aspx.cs" Inherits="FastTravel.IntranetWeb.OrderAdd" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
	<title>Создание заказа</title>
	<style type="text/css">
	h1{
			font-family: MyriadPro-Semibold, 'Myriad Pro Semibold', 'Myriad Pro', 'Trebuchet MS', Tahoma, arial, sans-serif;
			font-size: 90%;
			margin: 0px 0px 5px 0px;
			padding: 0px;
			text-shadow: #CCC 1px 1px 0;
			text-transform:uppercase;
		}
	p{
			font-family: MyriadPro-Semibold, 'Myriad Pro Semibold', 'Myriad Pro', 'Trebuchet MS', Tahoma, arial, sans-serif;
			font-size: 70%;
			margin: 0px 0px 0px 0px;
			padding: 0px;
		}
	</style>
	<ext:XScript ID="xScript" runat="server">
		<Script type="text/javascript">
			var clearFilter = function () {
				#{txtCustomerFilterFirstName}.reset();
				#{txtCustomerFilterLastName}.reset();
				#{txtCustomerFilterMiddleName}.reset();
				#{grdCustomer}.getStore().clearFilter();
			}
		</Script>
	</ext:XScript>
</head>
<body>
	<form id="formOrderAdd" runat="server">
		<ext:ResourceManager ID="resourceManager" runat="server" Theme="Gray" DirectMethodNamespace="FastTravel.IntranetWeb"/>

			<ext:Store ID="storeMarritialStatus" runat="server">
					<Reader>
					<ext:JsonReader IDProperty="Value">
						<Fields>
							<ext:RecordField Name="Text" />
							<ext:RecordField Name="Value" />
						</Fields>
					</ext:JsonReader>
				</Reader>           
			</ext:Store>

			<ext:Panel ID="wizardOrder" runat="server" Title="Мастер оформления заказа" Padding="10" Layout="card" ActiveIndex="0">       
			<Items>
				
				<ext:Panel ID="pnlCustomer" runat="server" Html="<h1>Клиенты</h1><p>Шаг 1 из 8</p>" Border="false" Header="false" Height="800">
					<Items>
						<ext:RowLayout runat="server" Split="true">
							<Rows>
								<ext:LayoutRow>
									<ext:Panel ID="pnlCustomerGrid" runat="server" TitleCollapse="true">
										<Items>

											<ext:GridPanel ID="grdCustomer" runat="server" Title="Клиенты компании" AutoHeight="true" StripeRows="true" AutoExpandColumn="LastName">
												
												<TopBar>
													<ext:Toolbar runat="server" ID="toolbarCustomer">
														<Items>
															<ext:Button runat="server" ID="btnCustomerAdd" Text="Новый клиент" Icon="Add">
																<DirectEvents>
																	<Click OnEvent="BtnCustomerAdd" />
																</DirectEvents>
															</ext:Button>
														</Items>
													</ext:Toolbar>
												</TopBar>

												<Store>
													<ext:Store ID="StoreCustomer" runat="server" OnRefreshData="CustomerStoreRefresh" RemoteSort="true" EnableTheming="true">
														<Proxy>
														   <ext:PageProxy />
														</Proxy>
														<Reader>
															<ext:JsonReader IDProperty="ID" TotalProperty="total">
																<Fields>
																	<ext:RecordField Name="ID" Type="Int"/>
																	<ext:RecordField Name="LastName" Type="String" />
																	<ext:RecordField Name="FirstName" Type="String" />
																	<ext:RecordField Name="MiddleName" Type="String" />
																	<ext:RecordField Name="AddedDate" Type="Date" SortDir="ASC"/>
																	<ext:RecordField Name="PhoneMobile" />
																	<ext:RecordField Name="PhoneWork" Type="Int"/>
																	<ext:RecordField Name="PhoneHome" Type="Int"/>
																	<ext:RecordField Name="Profession" Type="String"/>
																	<ext:RecordField Name="JobPlacement" Type="String"/>
																	<ext:RecordField Name="Email" Type="String"/>
																	<ext:RecordField Name="BirthDate" Type="Date"/>
																	<ext:RecordField Name="AddressLine1" Type="String"/>
																	<ext:RecordField Name="AddressLine2" Type="String"/>
																</Fields>
															</ext:JsonReader>
														</Reader>
														<BaseParams>
															<ext:Parameter Name="start" Value="0" Mode="Raw" />
															<ext:Parameter Name="limit" Value="10" Mode="Raw" />
															<ext:Parameter Name="sort" Value="AddedDate" />
															<ext:Parameter Name="dir" Value="ASC" />
														</BaseParams>
														<SortInfo Field="AddedDate" Direction="DESC" />
													</ext:Store>
												</Store>
												<ColumnModel ID="columnCustomer" runat="server" EnableTheming="true">
													<Columns>
														<ext:Column ColumnID="ID" Header="№" Width="40" DataIndex="ID"/>
														<ext:Column Header="Фамилия" Width="150" DataIndex="LastName"/>
														<ext:Column Header="Имя" Width="150" DataIndex="FirstName" />
														<ext:Column Header="Отчество" Width="150" DataIndex="MiddleName" />
														<ext:DateColumn Header="Регистация" Width="80" DataIndex="AddedDate" />
														<ext:Column Header="Моб. тел." Width="90" DataIndex="PhoneMobile" >
															<Renderer Handler="return (value > 0) ? value: '-';" />
														</ext:Column>
														<ext:CommandColumn Width="55" Header="Действ.">
														   <Commands>                                               
															  <ext:GridCommand CommandName="Edit" Icon="Pencil" ToolTip-Text="Изменить">                                                        
															  </ext:GridCommand>
															  <ext:GridCommand CommandName="Delete" Icon="Cross" ToolTip-Text="Удалить">
															  </ext:GridCommand>
														   </Commands>
														</ext:CommandColumn>
														<ext:Column Width="28" DataIndex="ID" Sortable="false" MenuDisabled="true" Header="&nbsp;" Fixed="true">
															<Renderer Handler="return '';" />
														</ext:Column>
														<ext:Column Width="28" DataIndex="ID" Sortable="false" MenuDisabled="true" Header="&nbsp;" Fixed="true">
															<Renderer Handler="return '';" />
														</ext:Column>
													</Columns>
												</ColumnModel>

												<DirectEvents>                                        
													<Command OnEvent="CustomerGridAction" Buffer="250">
														<EventMask ShowMask="true" />
															<ExtraParams>
																<ext:Parameter Name="command" Value="command" Mode="Raw"/>
																<ext:Parameter Name="id" Value="record.id" Mode="Raw"/>
															</ExtraParams>
															<Confirmation BeforeConfirm="if (command=='Edit') return false;" ConfirmRequest="true" Message="Вы хотите удалить клиента?" Title="Удаление клиента" />
													</Command>
												</DirectEvents>

												<View>
													<ext:GridView ID="grdFilter" runat="server" EnableTheming="true">
														<HeaderRows>
															<ext:HeaderRow>
																<Columns>
																	<ext:HeaderColumn/>
																	<ext:HeaderColumn>
																		<Component>
																			<ext:TextField runat="server" ID="txtCustomerFilterLastName" AllowBlank="true" SelectOnFocus="true">
																				<DirectEvents>
																					<SpecialKey Before="return e.getKey() == Ext.EventObject.ENTER;" OnEvent="BtnSearchCustomerClick"/>
																				</DirectEvents>
																			</ext:TextField>
																		</Component>
																	</ext:HeaderColumn>
								
																	<ext:HeaderColumn>
																		<Component>
																			<ext:TextField runat="server" ID="txtCustomerFilterFirstName" AllowBlank="true" SelectOnFocus="true">
																				<DirectEvents>
																					<SpecialKey Before="return e.getKey() == Ext.EventObject.ENTER;" OnEvent="BtnSearchCustomerClick"/>
																				</DirectEvents>
																			</ext:TextField>
																		</Component>
																	</ext:HeaderColumn>
								
																	<ext:HeaderColumn>
																		<Component>
																			<ext:TextField runat="server" ID="txtCustomerFilterMiddleName" AllowBlank="true" SelectOnFocus="true">
																				<DirectEvents>
																					<SpecialKey Before="return e.getKey() == Ext.EventObject.ENTER;" OnEvent="BtnSearchCustomerClick"/>
																				</DirectEvents>
																			</ext:TextField>
																		</Component>
																	</ext:HeaderColumn>

																	<ext:HeaderColumn/>
																	<ext:HeaderColumn/>

																	<ext:HeaderColumn>
																		<Component>
																			<ext:Button runat="server" ID="btnCustomerFilterAdd" Icon="Find" >
																				<ToolTips>
																					<ext:ToolTip ID="tipCustomerFindData" runat="server" Html="Поиск" />
																				</ToolTips>
																				<DirectEvents>
																					<Click OnEvent="BtnSearchCustomerClick" />
																				</DirectEvents>
																			</ext:Button>
																		</Component>	
																	</ext:HeaderColumn>

																	<ext:HeaderColumn AutoWidthElement="false">
																	<Component>
																		<ext:Button ID="ClearCustomerFilterButton" runat="server" Icon="Cancel">
																				<ToolTips>
																					<ext:ToolTip ID="tipCustomerClearFilter" runat="server" Html="Очистить фильтр" />
																				</ToolTips>
											 
																				<Listeners>
																					<Click Handler="clearCustomerFilter(null);" />
																				</Listeners>                                            
																			</ext:Button>
																		</Component>
																	</ext:HeaderColumn>

																</Columns>
															</ext:HeaderRow>
														</HeaderRows>
													</ext:GridView>
												</View>	
												<BottomBar>
													<ext:PagingToolbar ID="toolbarCustomerBottomPaging" runat="server" BeforePageText="Страница" AfterPageText="из" PageSize="10" DisplayInfo="true" DisplayMsg="Клиенты {0} - {1} из {2}      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" EmptyMsg="Нет клиентов"  LabelAlign="Left" EnableTheming="true">
														<Items>
															<ext:Label ID="lblCustomerPageSize" runat="server" Text="Размер страницы:" />
															<ext:ToolbarSpacer ID="toolbarCustomerSpacer" runat="server" Width="10" EnableTheming="true"/>
															<ext:ComboBox ID="comboCustomerPageSize" runat="server" Width="50" EnableTheming="true">
																<Items>
																	<ext:ListItem Text="10" />
																	<ext:ListItem Text="15" />
																	<ext:ListItem Text="20" />
																	<ext:ListItem Text="30" />
																	<ext:ListItem Text="50" />
																</Items>
																<SelectedItem Value="10" />
																<Listeners>
																	<Select Handler="#{toolbarCustomerBottomPaging}.pageSize = parseInt(this.getValue()); #{toolbarCustomerBottomPaging}.doLoad();" />
																</Listeners>
															</ext:ComboBox>
														</Items>
													</ext:PagingToolbar>
												</BottomBar>
												<SelectionModel>
															<ext:RowSelectionModel ID="rowCustomerSelectionModel" runat="server" SingleSelect="true" EnableTheming="true">
																<DirectEvents>
																	<RowSelect OnEvent="CustomerRowSelected" Buffer="100">
																		<EventMask ShowMask="true" Target="CustomTarget" CustomTarget="#{pnlDetail}" />
																		<ExtraParams>
																			<ext:Parameter Name="ID" Value="#{grdCustomer}.getSelectionModel().hasSelection() ? #{grdCustomer}.getSelectionModel().getSelected().id : -1" Mode="Raw" />
																		</ExtraParams>
																	</RowSelect>
																</DirectEvents>
															</ext:RowSelectionModel>
												</SelectionModel>
			
												<LoadMask ShowMask="true" Msg="Загрузка данных о клиентах..."/>

											</ext:GridPanel>
												

										</Items>
									</ext:Panel>
								</ext:LayoutRow>
					
								<ext:LayoutRow>
									<ext:Panel ID="pnlCustomerButton" runat="server" Title="" Height="35" TitleCollapse="true" ButtonAlign="Center">
										<Buttons>
											<ext:Button ID="btnCustomerChoose" runat="server" Icon="ArrowDown" Text="Добавить" >
												<DirectEvents>
													<Click OnEvent="BtnChooseCustomerClick" >
														<ExtraParams>
															<ext:Parameter Name="id" Value="#{grdCustomer}.getSelectionModel().hasSelection() ? #{grdCustomer}.getSelectionModel().getSelected().id : -1" Mode="Raw" />
														</ExtraParams>
													</Click>
												</DirectEvents>
												<ToolTips>
													<ext:ToolTip ID="tipCustomerChoose" runat="server" Title="Добавить" Html="Добавить выделенного клиента" />
												</ToolTips>
											</ext:Button>
											<ext:Button ID="btnCustomerRemove" runat="server" Icon="ArrowUp" Text="Убрать">
												<DirectEvents>
													<Click OnEvent="BtnRemoveCustomerClick" >
														<ExtraParams>
															<ext:Parameter Name="id" Value="#{grdCustomerInOrder}.getSelectionModel().hasSelection() ? #{grdCustomerInOrder}.getSelectionModel().getSelected().id : -1" Mode="Raw" />
														</ExtraParams>
													</Click>
												</DirectEvents>
												<ToolTips>
													<ext:ToolTip ID="tipCustomerRemove" runat="server" Title="Убрать" Html="Убрать клиента из списка" />
												</ToolTips>
											</ext:Button>
											<ext:Button ID="btnCustomerRemoveAll" runat="server" Icon="ArrowDivide" Text="Убрать всех">
												<DirectEvents>
													<Click OnEvent="BtnRemoveAllCustomerClick" />
												</DirectEvents>
												<ToolTips>
													<ext:ToolTip ID="tipCustomerRemoveAll" runat="server" Title="Убрать всех" Html="Убрать всех клиентов из списка" />
												</ToolTips>
											</ext:Button>	
										</Buttons>
									</ext:Panel>
								</ext:LayoutRow>
					
								<ext:LayoutRow>
									<ext:Panel ID="pnlCustomerChoosed" runat="server" Title="Клиенты для оформления" >
										<Items>
											
											 <ext:GridPanel ID="grdCustomerInOrder" runat="server" EnableDragDrop="false" AutoExpandColumn="FirstName" Height="200" TrackMouseOver="true">
												
												<Store>
													<ext:Store runat="server" ID="CustomerChoosedStore" OnRefreshData="StoreChoosedCustomersRefreshData">
														<Proxy>
														   <ext:PageProxy />
														</Proxy>
														<Reader>
															<ext:JsonReader IDProperty="ID" TotalProperty="total">
																<Fields>
																	<ext:RecordField Name="ID" Type="Int"/>
																	<ext:RecordField Name="LastName" Type="String" />
																	<ext:RecordField Name="FirstName" Type="String" />
																	<ext:RecordField Name="MiddleName" Type="String" />
																	<ext:RecordField Name="AddedDate" Type="Date" SortDir="ASC"/>
																	<ext:RecordField Name="ModifyDate" Type="Date"/>
																	<ext:RecordField Name="PhoneMobile" Type="Int"/>
																	<ext:RecordField Name="PhoneWork" Type="Int"/>
																	<ext:RecordField Name="PhoneHome" Type="Int"/>
																	<ext:RecordField Name="Profession" Type="String"/>
																	<ext:RecordField Name="JobPlacement" Type="String"/>
																	<ext:RecordField Name="Email" Type="String"/>
																	<ext:RecordField Name="BirthDate" Type="Date"/>
																	<ext:RecordField Name="AddressLine1" Type="String"/>
																	<ext:RecordField Name="AddressLine2" Type="String"/>
																</Fields>
															</ext:JsonReader>
														</Reader>
														<BaseParams>
															<ext:Parameter Name="start" Value="0" Mode="Raw" />
															<ext:Parameter Name="limit" Value="10" Mode="Raw" />
															<ext:Parameter Name="sort" Value="AddedDate" />
															<ext:Parameter Name="dir" Value="ASC" />
														</BaseParams>
														<SortInfo Field="LastName" Direction="DESC" />
													</ext:Store>
												</Store>

												<ColumnModel runat="server">
													<Columns>
														<ext:Column ColumnID="ID" Header="ID" DataIndex="ID" />   
														<ext:Column ColumnID="LastName" Header="Фамилия" DataIndex="LastName" />
														<ext:Column ColumnID="FirstName" Header="Имя" DataIndex="FirstName" />   
														<ext:Column ColumnID="MiddleName" Header="Отчество" DataIndex="MiddleName" />
														<ext:Column ColumnID="PhoneMobile" Header="Мобильный" DataIndex="PhoneMobile" />      
														<ext:DateColumn ColumnID="AddedDate" Header="Добавлен" DataIndex="AddedDate" />
														<ext:Datecolumn ColumnID="ModifyDate" Header="Изменен" DataIndex="ModifyDate" />                      
													</Columns>
												</ColumnModel>

												<SelectionModel>
													<ext:RowSelectionModel ID="rowSelectionCustomerInOrder" runat="server" />
												</SelectionModel>  

												<SaveMask ShowMask="true" Msg="Обновление выбранных клиентов..."/>

											</ext:GridPanel>
										
										</Items>
									</ext:Panel>
								</ext:LayoutRow>
							</Rows>
						</ext:RowLayout>
					</Items>
				</ext:Panel>

				<ext:Panel ID="pnlPrice" runat="server" Html="<h1>Стоимость</h1><p>Шаг 2 из 8</p>" Border="false" Header="false" >
					<Items>
					<ext:RowLayout ID="rowPrice" runat="server">
							<Rows>
								<ext:LayoutRow>
									<ext:GridPanel ID="grdPrice" runat="server" Title="Укажите цену тура">
										<Store>
											<ext:Store ID="StoreCustomerForOrder" runat="server">
												<Reader>
													<ext:JsonReader>
														<Fields>
															<ext:RecordField Name="ID" Type="Int" />
															<ext:RecordField Name="Text" Type="String" />
														</Fields>
													</ext:JsonReader>
												</Reader>
											</ext:Store>
										</Store>

										<Plugins>
											<ext:EditableGrid ID="price" runat="server" />
										</Plugins>
							
										<ColumnModel>
											<Columns>
												<ext:CheckColumn Header="Заказ" Width="60"/>
												<ext:Column ColumnID="ID" Header="№" Width="40" DataIndex="ID"/>
												<ext:Column Header="Фамилия" DataIndex="Value" Width="120" Sortable="false" />
												<ext:Column Header="Имя" DataIndex="Value" Width="120" Sortable="false" />
												<ext:Column Header="Отчество" DataIndex="Value" Width="120" Sortable="false" />
									
												<ext:Column Header="Туруслуга" DataIndex="Text" Width="80" Sortable="false">
													<Editor>
														<ext:TextField ID="txtTourService" runat="server" AllowBlank="false" Text="80000"/>
													</Editor>
												</ext:Column>
									
												<ext:Column Header="Валюта" DataIndex="Text" Width="80" Sortable="false">
													<Editor>
														<ext:ComboBox runat="server" ID="comboPriceTourService" SelectedIndex="0">
															<Items>
																<ext:ListItem Text="BYR" Value="BYR" />
																<ext:ListItem Text="USD" Value="USD" />
																<ext:ListItem Text="EUR" Value="EUR" />
																<ext:ListItem Text="RUR" Value="RUR" />
															</Items>
														</ext:ComboBox>
													</Editor>
												</ext:Column>
											</Columns>
										</ColumnModel>
									</ext:GridPanel>
								</ext:LayoutRow>
						</Rows>
					</ext:RowLayout>
					</Items>
				</ext:Panel>
				<ext:Panel ID="pnlDestination" runat="server" Html="<h1>Пункт назначения</h1><p>Шаг 3 из 8</p>" Border="false" Header="false" >

				</ext:Panel>
				<ext:Panel ID="pnlAgency" runat="server" Html="<h1>Принимающая сторона</h1><p>Шаг 4 из 8</p>" Border="false" Header="false" >

				</ext:Panel>
				<ext:Panel ID="pnlVehcle" runat="server" Html="<h1>Транспорт</h1><p>Шаг 5 из 8</p>" Border="false" Header="false" >

				</ext:Panel>
				<ext:Panel ID="pnlPlacement" runat="server" Html="<h1>Размещение</h1><p>Шаг 6 из 8</p>" Border="false" Header="false" >

				</ext:Panel>
				<ext:Panel ID="pnlFood" runat="server" Html="<h1>Питание</h1><p>Шаг 7 из 8</p>" Border="false" Header="false" >

				</ext:Panel>
				<ext:Panel ID="pnlConfirmationAndReport" runat="server" Html="<h1>Подтверждение заказа и договор</h1><p>Шаг 8 из 8</p>" Border="false" Header="false" >

				</ext:Panel>
				<ext:Panel ID="pnlNewOrder" runat="server" Html="<h1>Следующий заказ</h1>" Border="false" Header="false" >

				</ext:Panel>
			</Items>         
			<Buttons>
				<ext:Button ID="btnPrev" runat="server" Text="Назад" Disabled="true" Icon="PreviousGreen">
					<DirectEvents>
						<Click OnEvent="PrevClick">
							<ExtraParams>
								<ext:Parameter Name="index" Value="#{wizardOrder}.items.indexOf(#{wizardOrder}.layout.activeItem)" Mode="Raw" />
							</ExtraParams>
						</Click>
					</DirectEvents>
				</ext:Button>
				<ext:Button ID="btnNext" runat="server" Text="Вперед" Icon="NextGreen">
					<DirectEvents>
						<Click OnEvent="NextClick">
							<ExtraParams>
								<ext:Parameter Name="index" Value="#{wizardOrder}.items.indexOf(#{wizardOrder}.layout.activeItem)" Mode="Raw" />
							</ExtraParams>
						</Click>
					</DirectEvents>
				</ext:Button>
			</Buttons>     
		</ext:Panel>

			<ext:ToolTip ID="tooltipCustomer" runat="server" Target="={#{grdCustomerInOrder}.getView().mainBody}" Delegate=".x-grid3-row" TrackMouse="true">
				<Listeners>
					<Show Handler="var rowIndex = #{grdCustomerInOrder}.view.findRowIndex(this.triggerElement);this.body.dom.innerHTML = '<b>Дополнительно:</b><br/>Домашний телефон: ' + #{CustomerChoosedStore}.getAt(rowIndex).get('PhoneHome') + '<br/>Рабочий телефон: ' + #{CustomerChoosedStore}.getAt(rowIndex).get('PhoneWork') + '<br/><hr/>Адрес1: ' +  #{CustomerChoosedStore}.getAt(rowIndex).get('AddressLine1') + '<br/>Адрес2: ' + #{CustomerChoosedStore}.getAt(rowIndex).get('AddressLine2');" />
				</Listeners>
			</ext:ToolTip>  

	</form>
</body>
</html>
